package com.example.textviewactivity.Service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;

import com.example.textviewactivity.LoginSuccessActivity;

public class MyService extends Service {
    public MyService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        String name = intent.getStringExtra("name");
        String password = intent.getStringExtra("password");
        if ("".equals(name)||name.length()==0){
            Toast.makeText(this, "您的账号不符合规则,请重新输入", Toast.LENGTH_SHORT).show();
        }else{
            if ("".equals(password)){
                Toast.makeText(this, "密码不能为空,请重新输入", Toast.LENGTH_SHORT).show();
            }else{
                Intent in=new Intent(this, LoginSuccessActivity.class);
                in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(in);
            }
        }

        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
